<template>
  <div id="innerresult">
    <el-steps :active=3 simple style="margin-bottom: 20px">
      <el-step title="简介" icon="el-icon-info"></el-step>
      <el-step title="上传" icon="el-icon-upload2"></el-step>
      <el-step title="调整" icon="el-icon-setting"></el-step>
      <el-step title="结果" icon="el-icon-finished"></el-step>
    </el-steps>
    <el-row>
      <el-col :span="24">数据集 {{ FN }} 聚类结果内部指标，耗时 {{ CT }} 毫秒</el-col>
    </el-row>
    <el-divider content-position="left">Dunn Index</el-divider>
    <el-row>
      <el-col :span="12">Dunn指数：{{ Math.round(DI * 1000) / 1000 }}</el-col>
      <el-col :span="12">
        <el-rate v-model="rateDI" disabled show-score text-color="ff9900" :score-template=textDI></el-rate>
      </el-col>
    </el-row>
    <el-divider content-position="left">Davies-Bouldin Index</el-divider>
    <el-row>
      <el-col :span="12">DB指数：{{ Math.round(DBI * 1000) / 1000 }}</el-col>
      <el-col :span="12">
        <el-rate v-model="rateDBI" disabled show-score text-color="ff9900" :score-template=textDBI></el-rate>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "InnerResult",
  data() {
    return {
      DI: 0,
      DBI: 0,
      CT: 0,
      FN: "",
      rateDI: 2.5,
      rateDBI: 2.5,
      textDI: "loading",
      textDBI: "loading",
    }
  },
  mounted() {
    var that = this;
    axios.get("http://localhost:8080/in/result").then(
      function (response) {
        console.log(response.data)
        that.DI = response.data.DI;
        that.DBI = response.data.DBI;
        that.CT = response.data.COST_TIME;
        that.FN = response.data.FILE_NAME;
        var total = response.data.TOTAL;
        var posDI = response.data.DI_POS;
        that.textDI = "  Dunn指数共计算过 " + total + " 次, 本次排名第 " + posDI + " 名. ";
        var posDBI = response.data.DBI_POS;
        that.textDBI = "  DB指数共计算过 " + total + " 次, 本次排名第 " + posDBI + " 名. ";
        that.rateDI = 5.0 / total * (total - posDI + 1)
        that.rateDBI = 5.0 / total * (total - posDBI + 1)
      }, function (err) {
      })
  }
}
</script>

<style scoped>

</style>
